import React, { PureComponent } from 'react';
import { Form, DatePicker } from 'antd';
import moment from 'moment';
import styles from './index.less';

const FormItem = Form.Item;

export default class DateTime extends PureComponent {
  handleChange = (value) => {
    if (this.props.onChange) this.props.onChange(moment(value).format('YYYY/MM/DD HH:mm:ss'))
  }
  render() {
    const { props } = this.props;
    return (
      <div className={styles.taskListInp}>
        <FormItem colon={false} label={props.label}>
        <DatePicker
        style={{ width: 250 }}
        showTime
        format="YYYY/MM/DD HH:mm:ss"
        value={moment(new Date(props.value))}
        onChange={this.handleChange}
        />
        </FormItem>
      </div>
    );
  }
}
